<div class="tpl-content-page-title">订单信息</div>
<ol class="am-breadcrumb">
	<li><a href="#" class="am-icon-home">首页</a></li>
	<li><a href="#">云造型会员</a></li>
	<li class="am-active">会员信息</li>
</ol>
<div class="tpl-portlet-components">
	<div class="tpl-block">
		<div class="am-g">
			<div class="am-u-sm-12 am-u-md-6">
				<div class="am-btn-toolbar">
					<div class="am-btn-group am-btn-group-xs">
						<!-- <button type="button" class="am-btn am-btn-default am-btn-success bnt-add">
							<span class="am-icon-plus"></span> 添加订单
						</button> -->
						<!-- <button id="payId" type="button" class="am-btn am-btn-default am-btn-warning
						 bnt-update">
							<span class="am-icon-archive"></span> 结账
						</button>
						<button type="button" class="am-btn am-btn-default am-btn-danger">
							<span class="am-icon-trash-o"></span> 删除
						</button> -->
					</div>
				</div>
			</div>
			<div class="am-u-sm-12 am-u-md-3">
				<div class="am-input-group am-input-group-sm">
					<!-- <input type="text" class="am-form-field"> --> <span
						class="am-input-group-btn">
						<!-- <button
							class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search"
							type="button"></button> -->
					</span>
				</div>
			</div>
		</div>
		<div class="am-g">
			<div class="am-u-sm-12">
				<form class="am-form">
					<table class="am-table am-table-striped am-table-hover table-main">
						<thead>
							<tr>
								<th class="table-check"><input type="checkbox"
									class="tpl-table-fz-check"></th>
								<th class="table-title">商品名称</th>
								<th class="table-author am-hide-sm-only">商品价格</th>
								<th class="table-date am-hide-sm-only">设计师</th>
								
								<th class="table-email">会员名称</th>
								<th class="table-date am-hide-sm-only">手机号码</th>
								<th class="table-date am-hide-sm-only">付款方式</th>
								<th class="table-date am-hide-sm-only">账户余额</th>
								
								<!-- <th class="table-date am-hide-sm-only">付款时间</th> -->
								<th class="table-date am-hide-sm-only">操作</th>
							</tr>
						</thead>
						<tbody id="tbodyId">
							<tr>
								<td colspan="9">暂时没有订单！</td>
							</tr>
						</tbody>
					</table>
					<div class="am-cf">

						<div class="am-fr">
							<ul class="am-pagination tpl-pagination">
								<li><a class="first">首页</a></li>
								<li><a class="pre">上一页</a></li>
								<li><a class="next">下一页</a></li>
								<li><a class="last">尾页</a></li>
								<li><a class="rowCount">总记录数(0)</a></li>
								<li><a class="pageCount">总页数(1)</a></li>
								<li><a class="pageCurrent">当前页(1)</a></li>
							</ul>
						</div>
					</div>
					<hr>

				</form>
			</div>

		</div>
	</div>
	<div class="tpl-alert"></div>
</div>
<script type="text/javascript">
$(function(){
	doGetObjects()
	
	 //假如是修改
	$(".tpl-content-wrapper")
	 .on("click",".btn-pay-order",doLoadEditUI)
	 .on("click",".btn-del-order",doDeleteOrder)
});

// 删除订单信息
function doDeleteOrder(){
	debugger
	var url="order/doDeleteById";
	var id=$(this).parents("tr").data("id");
	var params={"id":id};	
	$.post(url,params,function(result){
		if(result.state==1){
			//alert(result.message);
			 doGetObjects()
		 }else{
			 alert(result.message);
		 }
	})
}

function doLoadEditUI(){
	  console.log("支付订单");
	  
	  var url="order/doFindOrderById";
	  var id=$(this).parents("tr").data("id");
	  var data={"id":id};
	  
	  $.getJSON(url,data,function(result){
		 if(result.state==1){
		    console.log(result.data)
		    $(".tpl-content-wrapper").data("data",result.data)
		    $(".tpl-content-wrapper").load("order-update.html");
			}else{
			  alert(result.message);
			}
		});
}

function doSaveOrderInfo(){
	$("#addOrderId").click(function(){
		$(".tpl-content-wrapper").load("order-add.html");
	});
} 

// 查询所有会员信息
function doGetObjects(){
	var url="order/doFindPageObjects";
	//debugger
	// 当前页数据
	var pageCurrent=$(".tpl-pagination").data("pageCurrent");
	if(!pageCurrent){pageCurrent=1;}
	// 参数
	var params={"pageCurrent":pageCurrent}
	var uname=$("#searchNameId").val();
	if(uname){
		params.username=uname;
	}
	$.getJSON(url,params,function(result){
		console.log(result)
		doHandleResponseResult(result)
	})
}

// 将响应的数据进行筛选判断
function doHandleResponseResult(result){
	if(result.state==1){
		doSetTablebody(result.data.records)
		doSetPagination(result.data);
	}else{
		//alert(result.message)
	}
}

// 追加数据
function doSetTablebody(records){
	// 获取tbodyId元素对象，并清空数据
	var tb=$("#tbodyId")
	tb.empty();
	// 循环追加
	for(var i in records){
		// 创建tr对象和tds对象
		var tr=$("<tr></tr>");
		tr.data("id",records[i].id);
		var tds=doCreateIds(records[i]);
		// 追加数据
		tr.append(tds);
		tb.append(tr);
	}
}

// 绑定数据
function doCreateIds(records){
	var ids="<td><input type='checkbox' class='cbox' value='"+records.id+"' /></td>"+
			"<td>"+records.itemName+"</td>"+
			"<td>"+records.itemPrice+"元整"+"</td>"+
			"<td>"+records.designer+"</td>"+
			
			"<td>"+records.memberName+"</td>"+
			"<td>"+records.memberMobile+"</td>"+
			"<td>"+records.payType+"</td>"+
			"<td>"+records.account+"元整"+"</td>"+
			
		    "<td><a class='btn-pay-order'>支付订单</a>"+
		    "&nbsp;<a class='btn-del-order'>删除</a></td>";
	return ids; // 返回绑定数据
}




</script>
<script type="text/javascript" src="../assets/js/page.js"></script>
</body>

</html>












